package com.cn.项目.飞机预约管理系统.Maininterface;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MSetPassenger extends JPanel implements ActionListener {
    JPanel p3 = null;
    public MSetPassenger(){
        JPanel p1 = new JPanel();
        p1.setLayout(new BorderLayout());
        JPanel p2 = new JPanel();
        p1.add(p2,"North");
        p2.setLayout(new GridLayout(1,4,20,0));
        JButton j1 = new JButton("增加乘客");
        j1.addActionListener(this);
        JButton j2 = new JButton("删除乘客");
        j2.addActionListener(this);
        JButton j3 = new JButton("修改乘客");
        j3.addActionListener(this);
        JButton j4 = new JButton("查看乘客");
        j4.addActionListener(this);

        p2.add(j1);
        p2.add(j2);
        p2.add(j3);
        p2.add(j4);

        p3 = new JPanel();
        p1.add(p3,"Center");

        this.add(p1);
        this.setVisible(true);
    }
    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand()=="增加乘客"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new AddPassenger01());
            p3.setVisible(true);
        }

        if (e.getActionCommand()=="删除乘客"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new DeletePassenger());
            p3.setVisible(true);
        }

        if (e.getActionCommand()=="修改乘客"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new UpdatePassenger());
            p3.setVisible(true);
        }

        if (e.getActionCommand()=="查看乘客"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new ShowPassenger01());
            p3.setVisible(true);
        }


    }
}
